#include <algorithm>
#include <cstdio>
#include <cstring>
constexpr int MaxN = 5e4 + 5;
constexpr int MaxM = 1e3 + 5;
int n, m;
char s[MaxN];
char t[MaxM];
int fail[MaxM];
int dp[MaxN][MaxM];
int next[MaxN][26];
int jump(int u, char by)
{
    int v = u;
    for (; v != 0 && t[v + 1] != by;)
    {
        v = fail[v];
    }
    return t[v + 1] == by ? v + 1 : v;
}
int main()
{
    freopen("neck.in", "r", stdin);
    freopen("neck.out", "w", stdout);
    scanf("%s", s + 1);
    scanf("%s", t + 1);
    n = strlen(s + 1);
    m = strlen(t + 1);
    fail[1] = 0;
    for (int i = 2; i <= m - 1; i++)
    {
        int v = fail[i - 1];
        for (; v != 0 && t[v + 1] != t[i];)
        {
            v = fail[v];
        }
        if (t[v + 1] == t[i] && v != i - 1)
        {
            v++;
        }
        fail[i] = v;
    }
    for (int i = 0; i <= m - 1; i++)
    {
        for (char j = 'a'; j <= 'z'; j++)
        {
            next[i][j - 'a'] = jump(i, j);
        }
    }
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            dp[i][j] = -1;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            if (dp[i][j] == -1)
            {
                continue;
            }
            int v = next[j][s[i + 1] - 'a'];
            if (v != m)
            {
                dp[i + 1][v] = std::max(dp[i + 1][v], dp[i][j] + 1);
            }
            dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j]);
        }
    }
    int answer = 0;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            answer = std::max(answer, dp[i][j]);
        }
    }
    printf("%d\n", answer);
    return 0;
}